// pages/wxlogin/wxlogin.js
let {wxlogin} = require('../../api/userApi');
Page({
  wxlogin(ev) {
    let {userInfo} = ev.detail;
    if(!userInfo) {return false};
    wx.login({
      complete : res => {
        let {code} = res;
        wxlogin(code).then(res => {
          console.log(res.data);
          let {token, uid} = res.data;
          let userInfo = {token,uid};
          wx.setStorageSync('userInfo', userInfo);
          wx.switchTab({
            url: '/pages/my/my',
          })
        })
      }
    })
  }
  
})